import { getData, postData, putData, deleteData } from '@/api/common/index';

const baseUserProfileInfo = '/api/user-profile-info';

const UserProfileInfoUrl = {
	page: '/new-page',
	exportInfo: '/export',
	url: '',
};

export function getUserProfileInfoPage(
	params: any,
	pageNo: number | null | undefined,
	pageSize: number | null | undefined,
): Promise<any> {
	let url =
		baseUserProfileInfo +
		UserProfileInfoUrl.page +
		'?pageNum=' +
		(pageNo ? pageNo : 1) +
		'&pageSize=' +
		(pageSize ? pageSize : 10);
	return postData(url, params);
}

export function getUserProfileInfoDetail(id: number): Promise<any> {
	return getData(baseUserProfileInfo + UserProfileInfoUrl.url + '?id=' + id);
}

export function deleteUserProfileInfo(ids: string): Promise<any> {
	return deleteData(
		baseUserProfileInfo + UserProfileInfoUrl.url + '?ids=' + ids,
	);
}

export function addOrEditUserProfileInfo(
	method: string,
	params: any,
): Promise<any> {
	if ('put' == method) {
		return putData(baseUserProfileInfo + UserProfileInfoUrl.url, params);
	} else {
		return postData(baseUserProfileInfo + UserProfileInfoUrl.url, params);
	}
}

export function exportUserProfileInfo(
	params: any,
	response: any,
): Promise<any> {
	const url = baseUserProfileInfo + UserProfileInfoUrl.exportInfo;
	return postData(url, params, response);
}
